<template id="user">
  <div align="center">
    <el-form :inline="true" class="demo-form-inline">
      <el-form-item label="输入关键字">
        <el-input v-model="keyWord" placeholder="想要搜索的内容"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="localData()">查询</el-button>
      </el-form-item>
    </el-form>

    <el-table
      ref="multipleTable"
      :data="memberList.list"
      tooltip-effect="dark"
      style="width: 100%"
      align="center"
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55" prop="id" align="center">
      </el-table-column>
      <el-table-column prop="users.user_name" label="会员姓名" width="100" align="center">
      </el-table-column>
      <el-table-column
        prop="balance"
        label="余额"
        width="100"
        sortable
        align="center"
      ></el-table-column>
    </el-table>

    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="memberList.pageNum"
      :page-sizes="[5, 10, 15, 20]"
      :page-size="5"
      layout="total, sizes, prev, pager, next, jumper"
      :total="memberList.total"
    >
    </el-pagination>
  </div>
</template>

<script>
export default {
  data() {
    return {
      memberList: {},
      currentPage: 1,
      pageSize: 5,
      ids: [],
      keyWord: "",
    };
  },

  methods: {
    localData() {
      this.$axios
        .get("/selAllMember", {
          params: {
            keyWord:this.keyWord,
            currentPage: this.currentPage,
            pageSize: this.pageSize,
          },
        })
        .then((res) => {
          this.memberList = res.data.data;
        })
        .catch((error) => {});
    },
    handleSizeChange(val) {
        this.pageSize = val;
        this.currentPage = 1;
        this.localData();
    },
    handleCurrentChange(val) {
        this.currentPage = val;
        this.localData();
    },
    handleSelectionChange(val) {
      var ids = []; //存放选中的id
      for (let item of val) {
        ids.push(item.id);
      }
      //将选中的所有项的id放到数据模型中
      this.ids = ids;

      console.log(ids);
      //this.multipleSelection = val;
    },
  },

  mounted() {
    // roleId=sessionStorage.getItem('roleId');
    this.localData();
  },
};
</script>